<template>
  <!-- 结算信息table组件 -->
  <div>
    <!-- <transition name="el-zoom-in-top">
      <div class="download" v-show="checkboxSelect > 0">
        <i class="el-icon-info"></i>
        共{{ total }}项，已选择<b>{{ checkboxSelect }}</b
        >项
        <span @click="excelDownload">下载</span>
        <em @click="cleanSelection">清空</em>
      </div>
    </transition> -->
    <el-table
      :data="tableData"
      @selectionChange="downloadWhether"
      stripe
      style="width: 100%"
      @selection-change="handleSelectionChange"
      ref="multipleTable"
      :row-key="getRowKeys"
      @sort-change="sortChange"
    >
      <!-- <template v-if="platformId != undefined || bussinessId != undefined">
        <el-table-column width="45"> </el-table-column>
      </template>
      <template v-else>
        <el-table-column type="selection" :reserve-selection="true" width="45"> </el-table-column>
      </template> -->
      <el-table-column prop="number" align="center" width="70" label="序号">
      </el-table-column>
      <el-table-column prop="settlementNo" sortable="custom" label="结算单编号" width="145">
      </el-table-column>
      <el-table-column prop="projectName" sortable="custom" label="项目名称">
      </el-table-column>
      <el-table-column prop="personNum" sortable="custom" label="发放人数">
      </el-table-column>
      <el-table-column prop="amount" sortable="custom" label="发放总金额">
        <template #default="item">
          {{ formatNumber(item.row.amount) }}
        </template>
      </el-table-column>
      <el-table-column prop="tax" sortable="custom" label="服务费率">
        <template #default="item">
          {{ formatNumber(item.row.feeRate) }}%
        </template>
      </el-table-column>
      <el-table-column prop="fee" sortable="custom" label="服务费">
        <template #default="item">
          {{ formatNumber(item.row.fee) }}
        </template>
      </el-table-column>
      <el-table-column prop="settlementAmount" sortable="custom" label="实付总金额">
        <template #default="item">
          {{ formatNumber(item.row.settlementAmount) }}
        </template>
      </el-table-column>
      <el-table-column
        prop="settlementStatus"
        align="center"
        label="发放状态"
        width="80"
      >
        <template #default="item">
          {{ settlementStatus[item.row.paymentStatuts] }}
        </template>
      </el-table-column>
      <el-table-column v-if="paymentStatuts1 == 2" prop="isApplyInvoice" label="是否开票">
        <template #default="item">
          {{ item.row.isApplyInvoice == 1 ? '是' : '否' }}
        </template>
      </el-table-column>
      <el-table-column prop="createTime" sortable="custom" label="建单时间" width="148">
        <template #default="item">
          <span v-if="item.row.createTime == null">--</span>
          <span v-else>{{ format("yyyy-MM-dd hh:mm:ss", new Date(item.row.createTime)) }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="platformPayTime" sortable="custom" label="发放时间" width="148">
        <template #default="item">
          <span v-if="item.row.platformPayTime == null">--</span>
          <span v-else>{{ format("yyyy-MM-dd hh:mm:ss", new Date(item.row.platformPayTime)) }}</span>
        </template>
      </el-table-column>
      <el-table-column
        v-if="paymentStatuts1 == 2"
        prop="caozuo"
        align="center"
        label="打款凭证"
        width="100"
        class-name="editor"
      >
        <template #default="item">
          <template v-if="item.row.paymentReceiptUrl == null || item.row.paymentReceiptUrl == ''"
            >-</template
          >
          <el-button
            v-else
            type="text"
            @click="openUrl(item.row.paymentReceiptUrl)"
            >查看</el-button
          >
        </template>
      </el-table-column>
      <el-table-column
        v-if="paymentStatuts1 == 2"
        prop="caozuo"
        align="center"
        label="打款明细"
        width="100"
        class-name="editor"
      >
        <template #default="item">
          <template v-if="item.row.paymentDetailUrl == null || item.row.paymentDetailUrl == ''"
            >-</template
          >
          <el-button
            v-else
            type="text"
            @click="openUrl(item.row.paymentDetailUrl)"
            >查看</el-button
          >
        </template>
      </el-table-column>
      <el-table-column
        prop="caozuo"
        label="操作"
        class-name="editor"
         width="180"
      >
        <template #default="item">
          <router-link
            :to="{
              path: 'settlementDels',
              query: { id: item.row.id,settleNo: item.row.settlementNo,businessName: item.row.businessName },
            }"
          >
            <el-button type="text">详情</el-button>
          </router-link>
          <el-button type="text" @click="excelDownload1(item.row)">下载确认单</el-button>
          <el-button type="text" v-if="item.row.paymentStatuts == 1" @click="selectSettleListByNo1(item.row)">发放</el-button>
          <el-button v-if="item.row.paymentStatuts == 1" @click="getUpdateSettlementStatus(item.row.settlementNo, 3 ,item.row.id)" type="text">作废</el-button>
           <!-- || item.row.paymentStatuts == 5 -->
          <!-- <el-button v-if="item.row.paymentStatuts == 1" type="text" @click="platformUploadPayCert(item.row)">打款情况</el-button> -->
        </template>
        <!-- <template v-if="item.row.paymentStatuts == 2"> -->
            <!-- <el-button type="text" @click="settlementService(item.row.settlementNo)"
              >打款明细</el-button
            > -->
            <!-- <el-button type="text" @click="settlementServices(item.row)"
              >打款情况</el-button
            > -->
          <!-- </template> -->
      </el-table-column>
    </el-table>

    <el-pagination
      v-if="tableData.length > 0"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="arrPage"
      :page-size="selectPage"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total"
    >
    </el-pagination>

    <!--查看平台打款情况 -->
    <el-dialog
      title="查看平台打款情况"
      custom-class="task-dialog"
      v-model="seeModule"
      width="70%"
    >
      <div class="add-border"></div>
      <div class="cardTits">
        <el-table :data="serviceArr" stripe style="width: 100%">
          <el-table-column prop="businessPayTime" label="企业打款时间" width="">
            <template #default="item">
              <template v-if="item.row.businessPayTime == null">-</template>
              <template v-else>
                {{
                  format(
                    "yyyy-MM-dd hh:mm:ss",
                    new Date(item.row.businessPayTime)
                  )
                }}
              </template>
            </template>
          </el-table-column>
          <el-table-column prop="idcrad" label="企业打款状态" width="">
            <template #default="item">
              {{ platformPaymetStatus[item.row.platformPaymetStatus] }}
            </template>
          </el-table-column>
          <el-table-column prop="idcrad" label="平台打款状态" width="">
            <template #default="item">
              {{ platformPaymetStatus[item.row.platformPaymetStatus] }}
            </template>
          </el-table-column>
          <el-table-column prop="platformPayTime" label="平台打款时间" width="">
            <template #default="item">
              <template v-if="item.row.platformPayTime == null">-</template>
              <template v-else>
                {{
                  format(
                    "yyyy-MM-dd hh:mm:ss",
                    new Date(item.row.platformPayTime)
                  )
                }}
              </template>
            </template>
          </el-table-column>
          <el-table-column prop="phone" label="平台打款凭证" width="" class-name="editor">
            <template #default="item">
              <template v-if="item.row.platformPaymentReceiptUrl == null"
                >-</template
              >
              <el-button
                v-else
                type="text"
                @click="openUrl(item.row.platformPaymentReceiptUrl)"
                >查看</el-button
              >
            </template>
          </el-table-column>
          <el-table-column prop="phone" label="平台打款明细" width="" class-name="editor">
            <template #default="item">
              <template v-if="item.row.platformPaymentDetailUrl == null"
                >-</template
              >
              <el-button
                v-else
                type="text"
                @click="openUrl(item.row.platformPaymentDetailUrl)"
                >查看</el-button
              >
            </template>
          </el-table-column>
        </el-table>
      </div>
      <template #footer>
        <span class="dialog-footer">
          <el-button type="primary" @click="seeModule = false">确 定</el-button>
        </span>
      </template>
    </el-dialog>


    <!-- 打款情况 -->
		<el-dialog title="打款凭证" custom-class="examine-style" v-model="selectSettleListByNo" width="40%">
			<div class="cardTits add-task">
        <el-form
            :model="taskForm"
            :rules="rules"
            ref="taskForm"
            label-width="150px"
            class="demo-ruleForm"
          >
          <el-form-item label="打款方式" prop="companyType">
              <el-select v-model="companyType" placeholder="请选择">
                <el-option label="线上" value="online"></el-option>
                <el-option label="线下" value="underline"></el-option>
              </el-select>
          </el-form-item>
          <div v-if="companyType == 'underline'">
            <el-form-item label="汇款回执单" required>
              <el-upload
                class="upload-demo"
                action=""
                accept="image/png,image/jpeg,application/pdf"
                :multiple="false"
                :limit="1"
                :file-list="fileList"
                :before-remove="file => beforeRemove('huizhiUrl')"
                :http-request="file => handleChange(file, 'huizhiUrl')"
              >
                <el-button size="small" plain>点击上传汇款回执单</el-button>
              </el-upload>
            </el-form-item>
            <el-form-item label="汇款明细">
              <el-upload
                class="upload-demo"
                action=""
                accept="image/png,image/jpeg,application/pdf,.xls,.xlsx"
                :multiple="false"
                :limit="1"
                :before-remove="file => beforeRemove('mingxiUrl')"
                :file-list="fileList"
                :http-request="file => handleChange(file, 'mingxiUrl')">
                <el-button size="small" plain>点击上传汇款明细</el-button>
              </el-upload>
            </el-form-item>
          </div>
        </el-form>
			</div>
      <template #footer>
        <span class="dialog-footer">
          <el-button @click="selectSettleListByNo = false">取 消</el-button>
          <el-button type="primary" @click="addTaskMethods1"
            >确 定</el-button
          >
        </span>
      </template>
		</el-dialog>

    <el-dialog title="下载确认单" custom-class="examine-style" v-model="excelDownloadShows" width="40%">
			<div class="cardTits">
				<div class="serveTime">选择服务时间：</div>
				<el-date-picker
                    v-model="value1"
                    type="daterange"
                    start-placeholder="开始时间"
                    end-placeholder="结束时间"
                    range-separator="~">
                 </el-date-picker>
			</div>
			<template #footer>
				<span class="dialog-footer">
				<el-button @click="addTaskMethods2">取 消</el-button>
				<el-button type="primary" @click="excelDownloadShow1"
					>确 定</el-button
				>
				</span>
			</template>
		</el-dialog>
  </div>
</template>

<script>
import axios from "axios";
import { ElLoading } from 'element-plus'
export default {
  props: ["bussinessId", "platformId", "search","personalType"],
  data() {
    return {
      cycleId: '',
      value1: '',
      startTime: '',
      endTime: '',
      serveTime: '',
      excelDownloadShows: false,
      fileList: [],
      fileUrl: {
        huizhiUrl: '',
        mingxiUrl: ''
      },
      taskForm: {
        bankExtendId: "",
        businessId: "", 
      },
      tableDatas2: [],
      dialogImageUrl: [],
      fileLists: [],
      seeModule: false,
      settleNos: '',
      dialogImageUrls: [],
      getRowKeys(row) {
        // 获取row的key值
        return row.id;
      },
      paymentStatuts: {
        1: "未打款",
        0: "未结算",
        2: "已打款",
        3: "废弃",
        4: "验证中"
      },
      platformPaymetStatus: {
        0: "未打款",
        1: "已打款",
      },
      settlementStatus: {
        // 结算状态
        1: "未打款",
        2: "已打款",
        3: "已作废",
        4: "部分打款",
        5: "平台审核中",
        6: "驳回",
      },
      authBankNos: '',
      companyType: '',
      paymentStatuts1: '',
      orderByZH: false,
      orderByAsc: false,
      businessNames: '',
      orderByColume: 'createTime',
      tableData: [],
      selectSettleListByNo: false,
      selectSettleListByNos: [],
      currentPage: 1,
      settlementNo: '',
      total: 0, // 总条数
      arrPage: [10, 20], // 每页条数
      selectPage: 10, // 每页选中条数
      checkboxSelect: 0,
      totals: 0,
      serviceShow: false, // 是否显示打款回执
      serviceArr: [],
      payMode: '',
      servicePayment: [],
      dakuanCurrentPage: 1,
      dakuanTotal: 0, // 总条数
      dakuanArrPage: [10, 20], // 每页条数
      dakuanSelectPage: 10, // 每页选中条数
      dwonloadList: [], // 选中的数据
      dakuanhuizhiShui: [],
      selectSettleListByNoId: '',
    };
  },
  created() {
    this.getTableAll();
  },
  methods: {
    setDateRanges(){
      for(var i = 0; i < this.tableDatas2.length; i++){
        if(this.tableDatas2[i].id == this.taskForm.bankExtendId){
          this.authBankNos = this.tableDatas2[i].authBankNo
          console.log(this.authBankNos)
        }
      }
    },  
    handleRemove(file, fileList) {
      console.log(file, fileList);
    },
    handleChange(param,name) {
      console.log(param)
      // 上传
			const form = new FormData()
      // 文件对象
      form.append('file', param.file)
      let loadingAlert = ElLoading.service({
          lock: true,
          text: '上传中...',
          customClass: 'custom-loading',
          spinner: 'el-icon-loading',
          background: 'rgba(0, 0, 0, 0.1)'
      })
			this.$http({
        method: "POST",
        url: "/api/quick/oss/uploadBySingle",
				headers: {
          "content-type": "multipart/form-data",
          // "Authorization": localStorage.getItem("bussines_token")
        },
        data: form
     }).then(data => {
        if(data.code == 0) {
          this.fileUrl[name] = data.result
        }else {
          this.$message.error("上传失败")
        }
        loadingAlert.close()
      })
    },
    beforeRemove(name) {
      this.fileUrl[name] = ''
    },
    handleRemoves(file, fileLists) {
      console.log(file, fileLists);
    },
    handleChanges(file,fileLists) {
      this.dialogImageUrls = [];
      for(var i = 0;i < fileLists.length; i++){
        this.dialogImageUrls.push(fileLists[i].url)
      }
    },
    selectSettleListByNo1(row){
      this.companyType = ''
      this.selectSettleListByNoId = row.id
      this.selectSettleListByNo = true
      this.settleNos = row.settlementNo
    },
    addTaskMethods1() {
      // console.log(this.fileUrl)
      if (this.companyType == '') {
        this.$message({
          message: '请选择打款方式',
          type: 'error',
          offset: 60
        })
      }else if(this.companyType == 'underline'){
        this.payMode = 2
        if(this.fileUrl.huizhiUrl == '') {
          this.$message.error('请上传汇款回执单')
          return false
        }else {
          this.$confirm('是否确认佣金发放?', '提示', {
            confirmButtonText: '确定',
            cancelButtonText: '取消',
            customClass: 'task-message',
            type: 'warning'
          }).then(() => {
            this.$http({
              url: '/api/quick/numb/updateNumb',
              method: 'post',
              headers: {
                'Content-Type': 'application/json'
              },
              data: {
                authPayCode: 0, // 审核状态
                payMode: this.payMode,
                paymentDetailUrl: this.fileUrl.mingxiUrl,
                paymentReceiptUrl: this.fileUrl.huizhiUrl,
                "pageNum": this.currentPage,
                "pageSize": this.selectPage,
                orderByAsc: this.orderByAsc, // 是否正序
                orderByColume: this.orderByColume, // 排序字段
                orderByZH: this.orderByZH, // 是否汉字
                paymentStatuts: 5,
                id: this.selectSettleListByNoId
              }
            }).then(data => {
              if(data.code === 0) {
                this.$message({
                  message: '上传成功',
                  type: 'success',
                  offset: 60
                })
                this.selectSettleListByNo = false
                this.getTableAll();
              }
            })
          }).catch(() => {
          });
        }
      }else if(this.companyType == 'online'){
        // 企业是否绑定税源地
        this.$http({
          url: "/api/quick/oem/business/checkBusinessTaxExtend",
          method: "post",
          headers: {
          "Content-Type": "application/json",
          },
        }).then((data) => {
          if (data.code == 0) {
            if (data.result) {
              this.payMode = 1
              this.$confirm('是否确认佣金发放?', '提示', {
                confirmButtonText: '确定',
                cancelButtonText: '取消',
                customClass: 'task-message',
                type: 'warning'
              }).then(() => {
                this.$http({
                  url: "/api/quick/numb/doNumbSalary",
                  method: "post",
                  headers: {
                  "Content-Type": "application/json",
                  },
                  data: {
                    payMode: this.payMode,
                    settleNo: this.settleNos,
                  },
                }).then((data) => {
                  if (data.code == 0) {
                    this.$message({
                        message: '发放成功',
                        type: 'success',
                        offset: 60
                      })
                      this.selectSettleListByNo = false
                      this.getTableAll();
                  }
                });
              }).catch(() => {
              });
            }else{
              this.$message({
                message: '银企直联线上模式税源地暂未接通，请选择银企直联线下模式',
                type: 'success',
                offset: 60
              })
            }
          }
        });
      }
    },
    getUpdateSettlementStatus(settlementNo, status ,id){
      // 结算单作废 确认结算单
      this.$http({
        url: "/api/quick/numb/discardNumb",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {
          id: id,
          settlementNo: settlementNo,
          settlementStatus: 1,
          paymentStatuts: status
        }
      }).then(d => {
        if(d.code == 0) {
          if(status == 3) {
            this.$message({
              message: '作废成功',
              type: 'success'
            });
          }
          this.getTableData()
        }
      })
      .catch(() => {
        this.$message({
          message: '作废失败',
          type: 'success'
        });
      });
    },
    getTableAll() {
      if (this.bussinessId) {
        // 企业结算
        this.getBussinessTableData();
      } else if (this.platformId) {
        this.getPlatformData();
      } else {
        this.getTableData();
      }
    },
    getTableData() {
      if(this.personalType == 0){
        this.paymentStatuts1 = ''
      }else {
        this.paymentStatuts1 = this.personalType
      }
      // 获取列表信息
      this.$http({
        url: "/api/quick/numb/getNumbPage",
        // url: "/api/quick/numb/getNumbDetailPage",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {
          paymentStatuts: this.paymentStatuts1,
          projectName: this.search, // 结算单号
          // businessId: "", // 个体工商户id
          // platformId: "", // 灵活用工平台id
          pageNum: this.currentPage,
          pageSize: this.selectPage,
          orderByAsc: this.orderByAsc, // 是否正序
          orderByColume: this.orderByColume, // 排序字段
          orderByZH: this.orderByZH, // 是否汉字
        },
      }).then((data) => {
        if (data.code === 0) {
          this.tableData = data.result.list;
          this.total = data.result.total;
        }
      });
    },
    getBussinessTableData() {
      // 获取企业结算列表信息
      this.$http({
        url: "/api/business/selectSettlementInfoByBusinessId",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {
          businessId: this.bussinessId, // 企业id
          mixedStr: "", // 灵活用工平台id
          pageNum: this.currentPage,
          pageSize: this.selectPage,
          orderByAsc: this.orderByAsc, // 是否正序
          orderByColume: this.orderByColume, // 排序字段
          orderByZH: this.orderByZH, // 是否汉字
        },
      }).then((data) => {
        if (data.code === 0) {
          this.tableData = data.result.list;
          this.total = data.result.total;
        }
      });
    },
    getPlatformData() {
      // 获取灵工平台结算列表信息
      this.$http({
        url: "/api/platform/selectSettlementInfoByPlatformId",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {
          platformId: this.platformId, // 企业id
          pageNum: this.currentPage,
          pageSize: this.selectPage,
          orderByAsc: this.orderByAsc, // 是否正序
          orderByColume: this.orderByColume, // 排序字段
          orderByZH: this.orderByZH, // 是否汉字
        },
      }).then((data) => {
        if (data.code === 0) {
          this.tableData = data.result.list;
          this.total = data.result.total;
        }
      });
    },
    sortChange(d) {
				// 监听排序
      if(d.prop == null) {
        // 默认排序方式
        this.orderByZH = false
        this.orderByAsc = false
        this.orderByColume = 'createTime'
      }else {
        let orderByZH = false
        if(d.prop == "businessName" || d.prop == "industyMsg" || d.prop == "platformName" || d.prop == "name") {
          orderByZH = true
        }
        this.currentPage = 1
        this.selectPage = 10
        let orderByAsc = d.order == "descending" ? false : true
        this.orderByZH = orderByZH
        this.orderByAsc = orderByAsc
        this.orderByColume = d.prop
      }
      if (this.bussinessId) {
        // 企业结算
        this.getBussinessTableData();
      } else if (this.platformId) {
        this.getPlatformData();
      } else {
        this.getTableData();
      }
    },
    sortChange1(d) {
				// 监听排序
      if(d.prop == null) {
        // 默认排序方式
        this.orderByZH = false
        this.orderByAsc = false
        this.orderByColume = 'createTime'
      }else {
        let orderByZH = false
        if(d.prop == "businessName" || d.prop == "industyMsg" || d.prop == "platformName" || d.prop == "name") {
          orderByZH = true
        }
        this.currentPage = 1
        this.selectPage = 10
        let orderByAsc = d.order == "descending" ? false : true
        this.orderByZH = orderByZH
        this.orderByAsc = orderByAsc
        this.orderByColume = d.prop
      }
      this.settlementService(this.settlementNo);
    },
    dakuanSizeChange(val) {
      // 打款回执切换每页条数调用
      this.dakuanSelectPage = val;
      this.settlementService(this.settlementNo)
    },
    dakuanCurrentChange(val) {
      // 打款回执切换当前页数调用
      this.dakuanCurrentPage = val;
      this.settlementService(this.settlementNo)
    },
    handleSelectionChange() {},
    handleSizeChange(val) {
      // 切换每页条数调用
      this.selectPage = val;
      this.getTableAll();
    },
    handleCurrentChange(val) {
      // 切换当前页数调用
      this.currentPage = val;
      this.getTableAll();
    },
    excelDownload() {
      // 下载
      let checkSelect = new FormData();
      for (let i = 0; i < this.dwonloadList.length; i++) {
        checkSelect.append("list", this.dwonloadList[i].id);
      }
      axios({
        method: "POST",
        url: "/api/settlement/settleListExcel",
        data: checkSelect,
        responseType: "blob",
        headers: {
          Authorization: localStorage.getItem("hegui_token"),
        },
      })
        .then((res) => {
          const blob = new Blob([res.data]);
          const downloadElement = document.createElement("a");
          const href = window.URL.createObjectURL(blob);
          //后台再header中传文件名
          downloadElement.href = href;
          downloadElement.download =
            "结算信息" + this.format("yyyyMMddhhmmss", new Date()) + ".xlsx";
          document.body.appendChild(downloadElement);
          downloadElement.click();
          document.body.removeChild(downloadElement); // 下载完成移除元素
          window.URL.revokeObjectURL(href); // 释放掉blob对象
        })
        .catch((err) => {
          console.log(err);
        });
    },
    downloadWhether(d) {
      this.checkboxSelect = d.length;
      this.dwonloadList = d;
    },
    cleanSelection() {
      // 清空选择
      this.$refs.multipleTable.clearSelection();
    },
    platformUploadPayCert(item) {
      // 查看平台打款情况
      this.$http({
        url: "/api/quick/finance/manage/querySettleByParam",
        method: "post",
        headers: {
          "Content-Type": "application/json",
          businessId: item.businessId,
        },
        data: {
          settlementNo: item.settlementNo,
          page: 1,
          size: 100,
        },
      }).then((data) => {
        if (data.code === 0) {
          this.seeModule = true;
          this.serviceArr = [data.result];
        }
      });
    },
    
    async settlementService(id) {
      // 获取个体服务费
      this.settlementNo = id;
      await this.$http({
        url: "/api/settlement/selectSettleSevicerListByNo",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {
          pageNum: this.dakuanCurrentPage,
          pageSize: this.dakuanSelectPage,
          businessId: "",
          settlementNo: id,
          platformId: "",
          orderByAsc: this.orderByAsc, // 是否正序
          orderByColume: this.orderByColume, // 排序字段
          orderByZH: this.orderByZH, // 是否汉字
        },
      }).then((data) => {
        if (data.code === 0) {
          this.totals = data.result.total
          this.serviceArr = data.result.list
          this.dakuanTotal = data.result.total
          this.seeModule = true;
        }
      });
      // 税费/服务费
      await this.$http({
        url: "/api/settlement/selectSettleTaxByPlatformId",
        method: "post",
        headers: {
          "Content-Type": "application/json",
        },
        data: {
          pageNum: 1,
          pageSize: 10,
          businessId: "",
          settlementNo: id,
          platformId: "",
          orderByAsc: this.orderByAsc, // 是否正序
          orderByColume: this.orderByColume, // 排序字段
          orderByZH: this.orderByZH, // 是否汉字
        },
      }).then((data) => {
        if (data.code === 0) {
          this.dakuanhuizhiShui = [data.result]
        }
      });
      // 打款回执
      this.serviceShow = true;
    },
    settlementServices(item){
      // 打款情况
      this.selectSettleListByNo = true;
      this.selectSettleListByNos = [item];
    },
    openUrl(url) {
      // 打开新窗口查看协议
      if(url === '' || url === null || url === undefined) return
      let str = url.substring(0, url.indexOf('?'))
      let suffix = str.substring(str.lastIndexOf('.'), url.length)
      if(suffix === '.PDF' || suffix === '.pdf') {
        window.open(url)
      }else {
        let newwin = window.open();
        newwin.document.write("<img src=" + url + " />");
      }
    },
    excelDownload1(row) {
      this.value1 = ''
      this.endTime = ''
      this.startTime = ''
      this.cycleId = row.id 
      this.excelDownloadShows = true;
      this.businessNames = row.businessName
    },
    addTaskMethods2() {
      this.excelDownloadShows = false
    },
    excelDownloadShow1() {
      // 获取列表信息
      if(this.value1){
        // this.format("yyyyMMddhh", new Date(this.value1[1]))
        this.endTime = this.format("yyyy年MM月dd日", new Date(this.value1[1]))
        this.startTime = this.format("yyyy年MM月dd日", new Date(this.value1[0]))
      }else {
        this.endTime = ''
        this.startTime = ''
      }
      this.serveTime = this.startTime + '-' + this.endTime
      let info = JSON.parse(localStorage.getItem("bussines_info"))
				// let checkSelect = new FormData();
				axios({
					method: "POST",
					url: "/api/quick/numb/downConfirmBill",
					data: {
						id: this.cycleId,
						cycle: this.serveTime
					},
					responseType: "blob",
					headers: {
						"businessType": 3,
						"websiteName": window.location.hostname,
            // "Authorization": localStorage.getItem("hegui_token"),
            "Authorization": localStorage.getItem("bussines_token"),
						"businessId": this.businessId,
						"businessNo": info.businessNo,
						"platformId": info.platformId,
						"platformNo": info.platformNo,
					},
				})
				.then((res) => {
				const blob = new Blob([res.data]);
				const downloadElement = document.createElement("a");
				const href = window.URL.createObjectURL(blob);
				//后台再header中传文件名
				downloadElement.href = href;
				downloadElement.download = "确认单-" + this.businessNames + '-' + this.format("yyyyMMddhhmmss", new Date()) + ".xlsx";
				document.body.appendChild(downloadElement);
				downloadElement.click();
				document.body.removeChild(downloadElement); // 下载完成移除元素
				window.URL.revokeObjectURL(href); // 释放掉blob对象
				this.excelDownloadShow = false
				})
				.catch((err) => {
				console.log(err);
				});
    }
  },
};
</script>
<style>
.el-message-box {
  width: 260px;
  text-align: initial;
}
.add-task .upload-demo {
    display: flex
;
}
.add-task .el-upload--text {
    width: auto;
    height: auto;
    border: 0;
    display: block;
    text-align: left;
}
.add-task .el-button--small {
    color: #326cf0;
    border-color: #326cf0;
}
</style>
<style scoped lang="scss">
.paymentThen {
  .pay-title {
    color: rgba(10, 46, 106, 1);
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: bold;
  }

  .pay-desc {
    color: #6c8198;
    margin-bottom: 20px;
    font-size: 12px;
  }

  .el-pagination {
    text-align: right;
  }

  .margin-top {
    margin-top: 20px;
  }
}
.cardTits {
  p {
    position: relative;
    top: -15px;
    font-size: 15px;
    color: #da2a2a;
  }
}
.serveTime {
	float: left;
    margin-left: 50px;
    position: relative;
    top: 10px;
}
</style>
